<?php
/**
 * Stone大叔?
 * ============================================================================
 * ----------------------------------------------------------------------------
 * <><><><><><><><><><><><><>有妹子加微信不哦！~<><><><><><><><><><><><><><><><>
 * ----------------------------------------------------------------------------
 * ============================================================================
 * $Author: Stone大叔💯 $
 * 2010-03-25 06:35:46Z Stone大叔💯 $
*/
namespace Stone;


//加载系统函数
if(!defined('IN_STONE')) {
	exit('Access Denied');
}

// 类文件后缀
define('EXT' , '.class.php');
//版本
define("STRON_VERSION", "1.0");


defined('ROOT_PATH')        ||  define('ROOT_PATH', dirname(__DIR__). DIRECTORY_SEPARATOR. 'application'. DIRECTORY_SEPARATOR);    #定义app路径
defined('FRAMEWORK_PATH')   ||  define('FRAMEWORK_PATH', substr(ROOT_PATH, 0, -12). 'Stone'. DIRECTORY_SEPARATOR);                     #定义框架路径

defined('CONFIG_PATH')        ||  define('CONFIG_PATH',       'Config' . DIRECTORY_SEPARATOR); // 配置目录
defined('FUNCTION_PATH')    ||  define('FUNCTION_PATH',     'Function' . DIRECTORY_SEPARATOR); // 公共函数目录
defined('TPL_PATH')    ||  define('TPL_PATH',     'Tpl' . DIRECTORY_SEPARATOR); // 错误模板目录
defined('LIB_PATH')    ||  define('LIB_PATH',     'Library' . DIRECTORY_SEPARATOR); // LIBrary目录 

defined('RUNTIME_PATH')     ||  define('RUNTIME_PATH',   ROOT_PATH . 'Runtime'. DIRECTORY_SEPARATOR);   // 系统运行时目录
defined('LOG_PATH')         ||  define('LOG_PATH',       RUNTIME_PATH . 'Logs' . DIRECTORY_SEPARATOR); // 应用日志目录
defined('TEMP_PATH')        ||  define('TEMP_PATH',      RUNTIME_PATH . 'Temp' . DIRECTORY_SEPARATOR); // 应用缓存目录
defined('DATA_PATH')        ||  define('DATA_PATH',      RUNTIME_PATH . 'Data' . DIRECTORY_SEPARATOR); // 应用数据目录
defined('CACHE_PATH')       ||  define('CACHE_PATH',     RUNTIME_PATH . 'Cache' . DIRECTORY_SEPARATOR); // 应用模板缓存目录

defined('MEMORY_LIMIT_ON')  || define('MEMORY_LIMIT_ON', true) ;    //是否记录内存运行时间

defined('IS_DEBUG')         || define('IS_DEBUG', false);

include FRAMEWORK_PATH . FUNCTION_PATH . 'function.php';
include FRAMEWORK_PATH  . 'Core'.DIRECTORY_SEPARATOR.'App.class.php';

//框架运行开始时间
G('_begin');
//框架初始化
\Stone\Core\App::_get_instance();
//加载配置
\Stone\Core\Config::load();
//加载日志
\Stone\Core\Log::init();
//参数跨站检测
\Stone\Core\XssCheck::check();  
//检查路由
\Stone\Core\Route::check();
//检查app目录结构
\Stone\Core\Build::checkDir();
//加载app配置文件
\Stone\Core\Config::loadAppConfig();
//加载勾子
\Stone\Core\Hook::init();

//准备
\Stone\Core\Hook::start("_core_ready");

$Controller     =       \Stone\Core\Route::getController();
$Model          =       \Stone\Core\Route::getModel();
$Action         =       \Stone\Core\Route::getAction();

$core           =   "\\{$Model}\\Controller\\$Controller";

if(!class_exists($core))
    E("Class non-existent:".$core);

if(!method_exists($core, $Action))
        E("method non-existent:".$Action);

define("ACTION", $Action);
define("MODEL", $Model);
define("CONTROLLER", $Controller);

$_core    =   new $core();

$_core->$Action();



